var orgid = RequestURLParam.getParam("orgid");
var cate = RequestURLParam.getParam("cate");
$(document).ready(function() {
    var formData = {
        'sysDuty.orgId': orgid
    };
    ActHttpRequest('SysOrgDuty!list.do', formData, function (data) {
        if (data.OK == "OK") {
            var htmlTxt = "";
            var srcTemIds = "";
            $("#def_ul_myrole").html(htmlTxt);
            for (var i = 0; i < data.List.length; i++) {
                var sysDuty = data.List[i];
                htmlTxt = '<li data_type="' + sysDuty.dutyLevel + '"  id="' + sysDuty.dutyId + '">';
                if ((sysDuty.orgType == 'cate' && sysDuty.orgId != orgid) || (sysDuty.dutyPid != null && sysDuty.dutyPid != "")) {
                    htmlTxt += '<a href="javascript:void(0);" onDblClick="dbl_myRole_Sel(\'' + sysDuty.dutyId + '\',\'' + sysDuty.dutyName + '\',\'' + sysDuty.orgType + '\');">' + sysDuty.dutyName + '(继承职务)</a></li>';
                } else {
                    htmlTxt += '<a href="javascript:void(0);" onDblClick="dbl_myRole_Sel(\'' + sysDuty.dutyId + '\',\'' + sysDuty.dutyName + '\');">' + sysDuty.dutyName + '</a></li>';
                }
                $("#def_ul_myrole").append(htmlTxt);
            }
			$("#def_ul_myrole li").each(function() {
				var index = parseInt($(this).attr("data_type"));
				var content = "------";
				for(var i = 0; i < index - 1; i++) {
					content += "------";
				}
				var before = document.createElement("before");
				$(before).css("color", "#ccc");
				before.innerHTML = content;
				this.insertBefore(before, this.firstChild);
			});
		} else {
			$("#def_ul_myrole").html('<li data_type="1"><a href="javascript:void(0);" style="color:red;" >请添加职务！</a></li>');

		}
	}, null, null, null, '加载中。。。', true);
});

function dbl_myRole_Sel(id, name) {
	window.CloseOwnerWindow({
		'id': id,
		'name': name
	});
}